/*Filename: scf.doPaper: Unemployment and the Distribution of LiquidityAuthors: Zachary Bethune, Guillaume RocheteauContact: bethune@rice.eduLast Modified: 8/22/23Purpose: compute moments*/clearclear matrixclear matacd "/Users/zbethune/Dropbox/Projects/WP/br-unemp/code/replication_file/empirical_data/do_files" cd ".././raw_data"use scf-sample-data.dtaset more off************************************************************************************************************************Means of liquid share by wealth decile - Figure 5***********************************************************************************************************************cd "../"local varlist liquid_sharelocal deciles 10 20 30 40 50 60 70 80 90 100local implist 1 2 3 4 5local yearlist 1998 2001 2004 2007 2010 2013capture file close tablefile open table using table_summary_decile_liquid_share.xls, write text replacefile write table "Variable" _tab "10" _tab "se" _tab "20" _tab "se" _tab "30" _tab "se" _tab "40" _tab "se" _tab "50" _tab "se" _tab "60" _tab "se" _tab "70" _tab "se" _tab "80" _tab "se" _tab "90" _tab "se" _tab "100" _tab "se" foreach y of local yearlist{	file write table _newline "year=`y'"	foreach i of local implist{		preserve		drop if year!=`y' | imp!=`i'		display "imp=`i'"		xtile dcile_wealth=wealth [pw=weight], nq(10)		replace dcile_wealth=dcile_wealth*10				file write table _newline "imp=`i'"		foreach q of local deciles {			quietly mean liquid_share if dcile==`q' [pweight=weight]			mat b = e(b)			local t = b[1,1]			file write table _tab %6.4f (`t')			mat s = e(V)			local t = s[1,1]			file write table _tab %6.4f (`t')		}		drop dcile		restore		}}file close table************************************************************************************************************************Means of liquid wealth to income by wealth decile - Figure 5***********************************************************************************************************************capture file close tablefile open table using table_summary_decile_liquid_income.xls, write text replacefile write table "Variable" _tab "10" _tab "se" _tab "20" _tab "se" _tab "30" _tab "se" _tab "40" _tab "se" _tab "50" _tab "se" _tab "60" _tab "se" _tab "70" _tab "se" _tab "80" _tab "se" _tab "90" _tab "se" _tab "100" _tab "se" foreach y of local yearlist{	file write table _newline "year=`y'"	foreach i of local implist{		preserve		drop if year!=`y' | imp!=`i'		display "imp=`i'"		xtile dcile_wealth=wealth [pw=weight], nq(10)		replace dcile_wealth=dcile_wealth*10				file write table _newline "imp=`i'"		foreach q of local deciles {			quietly mean liquid_income if dcile==`q' [pweight=weight]			mat b = e(b)			local t = b[1,1]			file write table _tab %6.4f (`t')			mat s = e(V)			local t = s[1,1]			file write table _tab %6.4f (`t')		}		drop dcile		restore		}}file close tablecd "./do_files"************************************************************************************************************************Calculate distributions - Figure 3***********************************************************************************************************************cd "../"cumul liquid_income [aw = weight], generate(liquid_income_cumul)sort liquid_income_cumuloutsheet liquid_income liquid_income_cumul using "liquid_income_dist.csv", comma nolabel replacecumul liquid_share [aw = weight], generate(liquid_share_cumul)sort liquid_share_cumuloutsheet liquid_share liquid_share_cumul using "liquid_share_dist.csv", comma nolabel replacecumul wealth_income [aw = weight], generate(wealth_income_cumul)sort wealth_income_cumuloutsheet wealth_income wealth_income_cumul using "wealth_income_dist.csv", comma nolabel replacecd "./do_files"